﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using FrienDev.BusinessRules;

/// <summary>
/// Summary description for ActivityInviteService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
[System.Web.Script.Services.ScriptService]
public class ActivityInviteService : System.Web.Services.WebService
{

    public ActivityInviteService()
    {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }


    [WebMethod(EnableSession = true)]
    public void SendSystemMessage(string[] receivers,string activityId)
    {
        for (int i = 0; i < receivers.Length; i++)
        {
            ApiHelper.Instance.SendSystemMessage("Activity"
                , "Invite"
                , UserRules.Instance.GetUserIdByUserName(receivers[i])
                , new string[]
                {   UserRules.Instance.GetCurrentUserId(),
                    UserRules.Instance.GetCurrentUser().FullName,
                    activityId,
                    ActivityRules.Instance.GetActivityInfo(int.Parse(activityId)).ActivityName
                });
        }
    }

    #region Protected Method
    protected int GetQueryStringValue(string QueryName, int nullValue)
    {

        if (string.IsNullOrEmpty(HttpContext.Current.Request.QueryString[QueryName]))
        {
            return nullValue;
        }
        return Convert.ToInt32(HttpContext.Current.Request.QueryString[QueryName]);
    }
    protected string GetQueryStringValue(string QueryName, string nullValue)
    {

        if (string.IsNullOrEmpty(HttpContext.Current.Request.QueryString[QueryName]))
        {
            return nullValue;
        }
        return HttpContext.Current.Request.QueryString[QueryName];
    }

    protected bool GetQueryStringValue(string QueryName, bool nullValue)
    {
        if (string.IsNullOrEmpty(HttpContext.Current.Request.QueryString[QueryName]))
        {
            return nullValue;
        }
        return Convert.ToBoolean(HttpContext.Current.Request.QueryString[QueryName]);
    }
    #endregion

}

